import { Navigate } from 'react-router-dom'
import react, { lazy } from 'react'

import Main from '../pages/main'
import Home from '../pages/home'
import Login from '../pages/login'

// import User from '../pages/user'
const User = react.lazy(() => import('../pages/user'))
// import PageOne from '../pages/other/pageOne'
const HomePage = react.lazy(() => import('../pages/personal/homePage'))
// import PageTwo from '../pages/other/pageTwo'
const VipPage = react.lazy(() => import('../pages/personal/vipPage'))
const Pay = react.lazy(() => import('../pages/personal/pay'))

const Article = react.lazy(() => import('../pages/article//index'))
const ArticleList = react.lazy(() => import('../pages/article/articleList'))
const ArticlePublish = react.lazy(() => import('../pages/article/articlePublish'))
const ArticleExamine = react.lazy(() => import('../pages/article/articleExamine'))
const ArticleType = react.lazy(() => import('../pages/article/articleType'))

const routes = [
  {
    path: '/',
    Component: Main,
    children: [
      {
        path: '/',
        element: <Navigate to="home" replace />
      },
      {
        path: 'home',
        Component: Home
      },
      {
        path: 'article',
        element: <Navigate to="/article/articleList" replace />
      },
      {
        path: 'article',
        children: [
          {
            path: 'articleList',
            Component: ArticleList
          },
          {
            path: 'articlePublish',
            Component: ArticlePublish
          },
          {
            path: 'articleExamine',
            Component: ArticleExamine
          },
          {
            path: 'articleType',
            Component: ArticleType
          }
        ]
      },
      {
        path: 'user',
        Component: User
      },
      {
        path: 'personal',
        element: <Navigate to="/personal/homePage" replace />
      },
      {
        path: 'personal',
        // element: <Navigate to="pageOne" replace />,
        children: [
          {
            path: 'homePage',
            Component: HomePage
          }
          // {
          //   path: 'vipPage',
          //   Component: VipPage
          // }
        ]
      }
    ]
  },
  {
    path: '/login',
    Component: Login
  },
  {
    path: '/pay',
    Component: Pay
  }
]

export default routes
export const routerMap = {
  articleList: ArticleList,
  articlePublish: ArticlePublish,
  articleExamine: ArticleExamine,
  articleType: ArticleType,
  user: User,
  homePage: HomePage,
  vipPage: VipPage
}
